package org.boulderfoodrescue.webapp.client.events;

import com.google.gwt.event.shared.GwtEvent;

public class MapsUpdatedEvent extends GwtEvent<MapsUpdatedHandler>{

	private static final Type<MapsUpdatedHandler> TYPE = new Type<MapsUpdatedHandler>();
	public enum ApiState{Loading, Loaded, Failed};
	private ApiState apiState;
	
  public MapsUpdatedEvent(ApiState apiState) {
  	this.apiState = apiState;
  }

  public static Type<MapsUpdatedHandler> getType() {
    return TYPE;
  }

  @Override
  public com.google.gwt.event.shared.GwtEvent.Type<MapsUpdatedHandler> getAssociatedType() {
    return TYPE;
  }
  
	@Override
  protected void dispatch(MapsUpdatedHandler handler) {
		switch(apiState)
		{
		case Loading: handler.onMapsApiLoadStart(this);return;
		case Loaded: handler.onMapsApiLoadSuccess(this);return;
		case Failed: handler.onMapsApiLoadFailed(this);return;
		}
  }

}
